home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / gpp-1_42.lha / g++-1.42.0 / crt1.c < prev    next >
C/C++ Source or Header  |  1991-10-19  |  1KB  |  46 lines

  1. /* This file provides the startup routine for files loaded with
  2.    the -A option of GNU ld.  When a program makes a call to the
  3.    initial address of code incrementally loaded, it expects that the
  4.    first function laid out in the object files loaded will
  5.    be the function called.  In GNU C++, we slip crt1.o in front of
  6.    the object files the user specifies, so that we can call any needed
  7.    global constructors, and set up calls for global destructors.
  8.    Control is then passed to the first routine that the user specified.  */
  9.  
  10. typedef struct set_vector {
  11.   unsigned int length;
  12.   unsigned int vector[1];
  13. } set_vector;
  14.  
  15. /*        ********  WARNING ********
  16.     Note that the address of _incstart() should be the start
  17.     of text space.
  18.  
  19.     Michael Tiemann, Stanford University.  */
  20.  
  21. extern set_vector __CTOR_LIST__;
  22. extern set_vector __DTOR_LIST__;
  23. extern set_vector *__dlp;
  24. extern int __dli;
  25. void (*_initfn)() = 0;
  26.  
  27. static void
  28. _incstart ()
  29. {
  30.   register void (**ppf)() = (void (**)())__CTOR_LIST__.vector;
  31.   int i, len = __CTOR_LIST__.length;
  32.  
  33.   __dli = __DTOR_LIST__.length;
  34.   __DTOR_LIST__.vector[__dli] = (int)__dlp;
  35.   __dlp = &__DTOR_LIST__;
  36.  
  37.   for (i = 0; i < len; i++)
  38.     (*ppf[i]) ();
  39.   (*_initfn)();
  40. }
  41.  
  42. static int
  43. _end_crt1 ()
  44. {
  45. }
  46.